<template>
  <div class="page-wrapper">
    <singInfo :onloaded="onload" :businessId="businessId" type="feeBack"/>
    <div class="btn-group">
      <template v-if="[0].indexOf(info.refundOrderStatus) > -1">
        <Button style="width: 100px" type="primary" @click="handleFeedBack">
          <Icon type="ios-checkmark" style="margin-right: 5px" />退款
        </Button>
        <Button v-if="info.ieffective !== 1" style="width: 100px; margin: 0 10px" type="error" @click="handleReject">
          <i class = "iconfont icon-butongyi" style="font-size:14px;margin-right:5px"></i>驳回
        </Button>
      </template>
      <Button style="width: 100px" @click="handleBack">
        <i class = "iconfont icon-butongyi" style="font-size:14px;margin-right:5px"></i>返回
      </Button>
    </div>
  </div>
</template>

<script>
import api from "@/api/commonApi";
import singInfo from "@/pages/components/patientSignDetail/signInfo";
export default {
  components: {
    singInfo,
  },  
  data() {
    return {
      ieffective: null,
      info: {},
      id: '',
      businessId: '',
    }    
  },
  created() {
    let breadList = [
      { path: "/index", title: "首页" },
      {
        path: "",
        title: "退费审批管理"
      },
      {
        path: "",
        title: "家医签约退费详情"
      }
    ];
    this.id = this.$route.query.id;
    this.businessId = this.$route.query.businessId;
  },
  methods: {
    handleBack() {
      this.$router.push({
        path: '/index/orders/feedBackMgt/list',
        query: this.$route.query
      });
    },
    handleFeedBack() {
      this.$Modal.confirm({
          content: '<p>你确定要同意退款吗？</p>',
          loading: true,
          onOk: () => {
            this.refundOperateAuditor(4);
          }
      });
    },
    handleReject() {
      this.$Modal.confirm({
          content: '<p>你确定要驳回退款吗？</p>',
          loading: true,
          onOk: () => {
              this.refundOperateAuditor(2);
          }
      });
    },
    onload(info) {
      this.info = info;
    },
    refundOperateAuditor(type) {
        const reqBody = {
          orderStatus: type,
        };
        this.$axios.post(api.RefundAuditor.replace('{id}', this.$route.query.id), reqBody).then(resp => {
          this.$Message.success('操作成功');
          this.handleBack();
          this.$Modal.remove();
        }).catch(err => {
          this.$Modal.remove();
        });
    }
  }

}
</script>

<style scoped lang="less">
.page-wrapper {
  padding: 10px 0;
    width: 100%;
    background: #ffffff;
    box-sizing: border-box;
}
  .btn-group {
    margin-top: 20px;
    text-align: center;
    margin-bottom: 10px;
  }
</style>